package cn.hellochaos.generator.mapper;

import cn.hellochaos.generator.entity.CaipuList;
import cn.hellochaos.generator.entity.FenleiCaipu;
import cn.hellochaos.generator.entity.vo.FenLeiVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* <p>
* 菜谱分类标签 Mapper 接口
* </p>
*
* @author test
* @since 2021-01-23
*/
@Mapper
@Repository
public interface FenleiCaipuMapper extends BaseMapper<FenleiCaipu> {

    @Select("SELECT\n" +
            "\ta.tag_category as category,\n" +
            "\tGROUP_CONCAT( DISTINCT tag ) as category_info\n" +
            "FROM\n" +
            "\t( SELECT tag_category, tag FROM fenlei_caipu ) AS a \n" +
            "GROUP BY\n" +
            "\ttag_category")
    List<FenLeiVo> getFenlei();

    @Select({"SELECT\t* FROM\n" +
            "\tcaipu_list\n" +
            "\tWHERE\n" +
            "\ttags\n" +
            "\tlike  '%${category}%'" +
            "\tLIMIT\n" +
            "\t0,15"})
    List<CaipuList> getCaipuListByCategory(@Param("category") String category);

}
